#!/bin/bash

# RuoYi-TDesign 项目 Docker 部署脚本

echo "开始构建 RuoYi-TDesign 项目 Docker 镜像..."

# 创建必要的目录
echo "创建必要的目录..."
mkdir -p ./script/docker/mysql/data
mkdir -p ./script/docker/mysql/conf
mkdir -p ./script/docker/redis/conf
mkdir -p ./script/docker/redis/data
mkdir -p ./script/docker/minio/data
mkdir -p ./script/docker/minio/config
mkdir -p ./script/docker/admin/logs
mkdir -p ./script/docker/monitor/logs
mkdir -p ./script/docker/snailjob/logs
mkdir -p ./logs

# 构建后端服务
echo "构建后端服务..."
cd ruoyi-admin
mvn clean package -DskipTests
cd ..

# 构建并启动所有服务
echo "使用 docker-compose 启动所有服务..."
docker-compose up -d

# 等待服务启动并初始化数据库
echo "等待服务启动..."
sleep 30

# 初始化数据库
echo "初始化数据库..."
./init-db.sh

echo "部署完成！"
echo "前端访问地址: http://localhost"
echo "后端接口地址: http://localhost:8080"
echo "查看运行状态: docker-compose ps"
echo "查看日志: docker-compose logs -f"